<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="|#{customer.systemTitle}-用户权限-资源管理|">交通部</title>
<div th:replace="fragments/head_admin">head</div>
<!--/* 当前页css */-->
<link rel="stylesheet" type="text/css" th:href="@{/resources/vendor/tgCube/css/libs/dataTables.fixedHeader.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/resources/vendor/tgCube/css/libs/dataTables.tableTools.css}" />
<!--/* Switch复选框按钮  修改是否可用用*/-->
<link th:href="@{/resources/vendor/bootstrap/plugins/toggle/css/bootstrap-toggle.min.css}" rel="stylesheet" />
<link th:href="@{/resources/vendor/treeTable/themes/vsStyle/treeTable.min.css}" rel="stylesheet" />
</head>
<body class="theme-turquoise fixed-header fixed-leftmenu fixed-footer">
	<div id="theme-wrapper">
		<div th:replace="fragments/nav_admin">导航栏</div>
		<div id="page-wrapper" class="container">
			<div th:replace="fragments/menu_admin::menu(root=uum,current=resource)">菜单栏</div>
			<div id="content-wrapper">
				<div th:replace="fragments/breadcrumbs_admin::breadcrumbs(parent=统一用户管理,current=资源管理)">面包屑栏</div>
				<div class="main-box clearfix">
					<header class="main-box-header clearfix">
						<div class="row m-b-sm m-t-sm">
							<div class="col-xs-8">
								<a th:href="@{/admin/c/resource/add_0.gsp}" data-target="#commonWin" class="btn btn-primary btn-sm" type="button" data-toggle="modal"><i class="fa fa-plus"></i>&nbsp;新增</a>
							</div>
						</div>
					</header>
					<div class="main-box-body clearfix">
						<table id="dataTable" cellspacing="0" width="100%" class="table table-striped table-hover ">
							<thead>
								<tr>
									<th>资源名称</th>
									<th width="100" class="text-center">状态</th>
									<th>资源代码</th>
									<th>资源标志</th>
									<th>资源URI</th>
									<th class="text-center">资源类型</th>
									<th class="text-center">编辑模式</th>
									<th class="text-center">排序</th>
									<th width="180" class="text-center">操作</th>
								</tr>
							</thead>
							<tbody id="dataTableDiv">
								<tr th:each="resource:${resources}" th:attr="id=${resource.id},pId=${resource.parentId=='-1'?0:resource.parentId}">
									<td th:text="${resource.resourceName}">资源名称</td>
									<td class="text-center"><input th:if="${resource.editable==1}" th:checked="${resource.enabled==1}" type="checkbox" data-size="mini" data-toggle="toggle" class="js-switch" data-on="启用" data-off="停用" th:attr="onchange='changeEnabled(this)',resourceId=${resource.id}" /> <input
										th:if="${resource.editable!=1}" type="checkbox" data-size="mini" class="js-switch disabled" data-on="启用" data-off="停用" checked="checked" /></td>
									<td th:text="${resource.codeNum}">资源代码</td>
									<td th:text="${resource.permission}">资源标志</td>
									<td th:text="${resource.permValue}">资源URI</td>
									<td th:switch="${resource.type}" class="text-center"><span class="text-info" th:case="1">菜单</span><span class="text-danger" th:case="2">按钮</span><span class="text-warning" th:case="3">方法</span></td>
									<td th:switch="${resource.editable}" class="text-center"><span class="text-success" th:case="1">可编辑</span><span class="text-danger" th:case="2">不可编辑</span></td>
									<td th:text="${resource.sortOrder}" class="text-center">排序</td>
									<td class="text-center">
									<a th:href="@{/admin/c/resource/edit_{id}.gsp(id=${resource.id})}" data-target="#commonWin" data-toggle="modal" class="btn btn-primary btn-xs"><i class="fa fa-pencil"></i></a> 
									<a th:href="@{/admin/c/resource/add_{id}.gsp(id=${resource.id})}" data-target="#commonWin" class="btn btn-info btn-xs btn-outline" type="button" data-toggle="modal"><i class="fa fa-plus"></i>&nbsp;新增子资源</a> 
									<a href="#" type="button" onclick="deleteItem(this)" th:attr="resourceId=${resource.id}" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i></a></td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<div th:replace="fragments/footer_admin">底部</div>
			</div>
		</div>
	</div>
</body>
<div th:replace="fragments/import_js_admin">引入js</div>
<!--/* 当前页js */-->
<!--/***** 当前页js start *****/-->
<script th:src="@{/resources/vendor/tgCube/js/jquery.dataTables.js}"></script>
<script th:src="@{/resources/vendor/tgCube/js/dataTables.fixedHeader.js}"></script>
<script th:src="@{/resources/vendor/tgCube/js/dataTables.tableTools.js}"></script>
<script th:src="@{/resources/vendor/tgCube/js/jquery.dataTables.bootstrap.js}"></script>
<!--/* Switch复选框按钮  修改是否可用用*/-->
<script th:src="@{/resources/vendor/bootstrap/plugins/toggle/js/bootstrap-toggle.min.js}"></script>
<script th:src="@{/resources/vendor/treeTable/jquery.treeTable.min.js}"></script>
<!--/***** 当前页js end *****/-->
<!--/***** 当前页js end *****/-->
<script th:inline="javascript">
    /*<![CDATA[*/
    //加载完成后执行
    $(function() {
        var option = {
            expandLevel : 3,
            onSelect : function($treeTable, id) {
                window.console && console.log('onSelect:' + id);
            }
        };
        $('#dataTable').treeTable(option);
    });

    var enableUrlPath = /*[[@{/admin/c/resource/enable_{id}.gsp}]]*/'url';
    var disableUrlPath = /*[[@{/admin/c/resource/disable_{id}.gsp}]]*/'url';
    var deleteUrlPath = /*[[@{/admin/c/resource/delete_{id}.gsp}]]*/'url';
    function changeEnabled(c) {
        var id = $(c).attr("resourceId");
        tg_changeEnabled(c, id, enableUrlPath.replace("{id}", id), disableUrlPath.replace("{id}", id));
    }
    function deleteItem(c){
        var id = $(c).attr("resourceId");
        tg_dleteItem(deleteUrlPath.replace("{id}", id), function(){
            location.href = /*[[@{/admin/c/resource/list.gsp}]]*/'';
        });
    }
    /*]]>*/
</script>
</html>